﻿using ProxyWrapper.UserProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class EmailIds : System.Web.UI.Page
{
    string userId = "";
    UserDetails _objUser = null;
    ProxyWrapper.UserServiceWrapper _wrap = null;
    string commentId = "";
    string _userName = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserObject"] != null)
            _objUser = ((ProxyWrapper.UserProxy.UserDetails)Session["UserObject"]);
        else
            Response.Redirect("Default.aspx", true);
        if (!Page.IsPostBack)
        {
            try
            {
                _wrap = new ProxyWrapper.UserServiceWrapper();
                btnSubmit.Text = "Add Email Ids";
                txtEmail.Text = _wrap.GetEmailIds(_objUser.UserId.ToString());
            }
            catch (Exception ex)
            {
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            _wrap = new ProxyWrapper.UserServiceWrapper();
            int cid = 0;
            string msg = _wrap.AddEMailIds(_objUser.UserId.ToString(), _objUser.UserId.ToString(),txtEmail.Text);
            Int32.TryParse(msg, out cid);
            if (cid <= 0)
                js.InnerHtml = ("<script>Confirmation('" + msg + "');</script>");
            else
                Response.Write("<script>alert('Email Id(s) added successfully!');  window.opener.location.reload(); window.close();</script>");
            // Response.Write(msg);
        }
        catch (Exception)
        {
        }
    }
}